package com.example.mainstream.ui.user;

import android.media.MediaPlayer;
import android.widget.MediaController;
import android.widget.Toast;

import com.example.shopapp.R;
import com.example.shopapp.databinding.ActivityVideoBinding;

import cn.project.base.baseui.BaseNormalActivity;

public class VideoActivity extends BaseNormalActivity<ActivityVideoBinding> {



    @Override
    protected int getLayoutId() {
        return R.layout.activity_video;
    }

    @Override
    protected void initView() {
        String path = getIntent().getStringExtra("detail");

        mBinding.video.setVideoPath(path);
        /**
         * 控制视频的播放 主要通过MediaController控制视频的播放
         */
        //创建MediaController对象
        MediaController mediaController = new MediaController(this);
        mBinding.video.setMediaController(mediaController); //让videoView 和 MediaController相关联
        mBinding.video.setFocusable(true); //让VideoView获得焦点
        mBinding.video.start(); //开始播放视频
        //给videoView添加完成事件监听器，监听视频是否播放完毕
        mBinding.video.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
            @Override
            public void onCompletion(MediaPlayer mp) {
                Toast.makeText(VideoActivity.this, "该视频播放完毕！", Toast.LENGTH_SHORT).show();
            }
        });


    }

    @Override
    protected void initData() {

    }

}
